import unittest
from ganstore import app


class GanStoreTest(unittest.TestCase):
    def setUp(self):
        print 'setUp'
        app.config['TESTING'] = True
        self.app = app.test_client()

    def tearDown(self):
        print 'tearDown'

    def home(self):
        return self.app.get('/api/home/index/')

    def seller(self):
        return self.app.post('/api/seller/getlist/', data={'page': 1})

    def seller_datails(self):
        return self.app.post('/api/seller/index/', data={'seller_id': 1})

    def goods(self):
        return self.app.post('/api/goods/getlist/', data={'page': 1})

    def goods_details(self):
        return self.app.post('/api/product/index/', data={'pro_id': 1})

    def test_url(self):
        assert self.home().status_code == 200
        assert 'hotSellers' in self.home().data
        assert 'banner' in self.home().data
        assert 'hotTreads' in self.home().data
        assert self.seller().status_code == 200
        assert 'sellers' in self.seller().data
        assert self.seller_datails().status_code == 200
        assert 'treads' in self.seller_datails().data
        assert 'sellers' in self.seller_datails().data
        assert self.goods().status_code == 200
        assert 'goods' in self.goods().data
        assert self.goods_details().status_code == 200
        assert 'images' in self.goods_details().data
        assert 'treads' in self.goods_details().data
        assert 'sellers' in self.goods_details().data
